<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp" %>
<html style="overflow: auto;">
	<head>
		<title>生产单</title>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8">
		<meta name="decorator" content="ani"/>
		<%@ include file="/webpage/include/bootstraptable.jsp" %>
		<%@include file="/webpage/include/treeview.jsp" %>
		<style>
			html{
				width: 100vw;
			}
			.layui-layer-content{
				height: calc(100% - 41px);
				overflow-y: scroll;
				-webkit-overflow-scrolling: touch !important;
				width: 100%;
			}
			.form_datetime{
				width: 100%;
			}
			.bootstrap-table .fixed-table-body{
				height: auto;
				overflow-y: hidden;
			}
		</style>
		<script type="text/javascript">
			var allParams = {};
			function setAllParams(){
				allParams = {};
				var stockroomName = $('#stockroomName').val().trim();
				var rentType = $('#rentType').val();
				var orderNo = $('#orderNo').val().trim();
				var createName = $('#createName').val().trim();
				if(stockroomName){
					allParams.stockroomName = stockroomName;
				}
				if(rentType!='all'){
					allParams.rentTypeValue = rentType;
				}
				if(orderNo){
					allParams.no = orderNo;
				}
				if(createName){
					allParams.createName = createName;
				}
			}

			$(document).ready(function(){
				var c = $(window.parent.document.body);
				c.find('.layui-layim-min').hide();
			});

			$(window).unload(function(){
				console.log("Goodbye");
				var c = $(window.parent.document.body);
				c.find('.layui-layim-min').show();
			});

			$(function () {
				getbaseList();
				// $('#startDate').datetimepicker({
				// 	format: "YYYY-MM-DD"
				// });
				// $('#endDate').datetimepicker({
				// 	format: "YYYY-MM-DD"
				// });
			});


			function getbaseList() {
				var touchtime;
				$("#table").bootstrapTable('destroy');
				$("#table").bootstrapTable({ // 对应table标签的id
					url: "${ctx}/sc/order/order/data",
					contentType: "application/x-www-form-urlencoded",
					cache: false, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
					striped: true,  //表格显示条纹，默认为false
					method: "get",
					dataType: "json",
					pagination: true, // 在表格底部显示分页组件，默认false
					pageList: [10, 50, 100], // 设置页面可以显示的数据条数
					pageSize: 10, // 页面数据条数
					pageNumber: 1, // 首页页码
					sidePagination: 'server', // 设置为服务器端分页
					clickToSelect: true,
					paginationFirstText: "首页",
					paginationPreText: '上一页',
					paginationNextText: '下一页',
					paginationLastText: '最后一页',
					smartDisplay: false,
					queryParams: function (params) {
						setAllParams();
						var searchParam = {...allParams};
						searchParam.pageNo = params.limit === undefined ? "1" : params.offset / params.limit + 1;
						searchParam.pageSize = params.limit === undefined ? -1 : params.limit;
						searchParam.orderBy = params.sort === undefined ? "" : params.sort + " " + params.order;
						// console.log(searchParam)
						return searchParam;
					},
					onDblClickRow: function(row){
						console.log('你双击了~~')
					},
					columns: [
						{
							checkbox: true
						},
						{
							title: '序号',
							align: 'center',
							width: 50,
							formatter: function(v, row ,index){
								let page = $('#table').bootstrapTable("getPage");
								return page.pageSize * (page.pageNumber - 1) + index + 1;
							}
						},
						{
							field: 'no',
							title: '订单号',
							align: 'center',
							width: 200
						}
						, {
							field: 'rentType',
							title: '订单类型',
							align: 'center',
							width: 100
						}
						, {
							field: 'workflowState',
							title: '流程',
							align: 'center',
							width: 100
						}
						, {
							field: 'stockroomName',
							title: '仓库名称',
							align: 'center',
							width: 300
						}
						, {
							field: 'createName',
							title: '创建人',
							align: 'center',
							width: 100
						}
						, {
							field: 'state',
							title: '审批状态',
							align: 'center',
							width: 100
						}
						, {
							field: 'remarks',
							title: '备注',
							align: 'center',
							width: 300
						}
						, {
							field: 'createDate',
							title: '创建时间',
							align: 'center',
							width: 250
						}
						, {
							field: 'qcDate',
							title: '质检时间',
							align: 'center',
							width: 250
						}
						, {
							field: '',
							title: '操作',
							align: 'center',
							width: 100,
							formatter: function (value, row, index) {
								return ''
							}
						}
					]
				})
			}

			// 查询
			function subForm() {
				$('#table').bootstrapTable('selectPage',1);
				// getbaseList()
			}
			// 重置
			function resca() {
				$("#stockroomName").val('');
				$("#orderNo").val('');
				$("#createName").val('');

				$('#table').bootstrapTable('selectPage',1);
				// getbaseList()
			}

		</script>

<body style="height:100%; overflow: scroll; -webkit-overflow-scrolling: touch;">
	<div class="wrap">
		<div class="layui-tab" style="padding-bottom:0px;">
			<div class="panel panel-default">
				<div class="panel-heading"><h3>查询</h3></div>
				<div class="panel-body">
					<div class="row" style="margin-left:5px; margin-top:10px;margin-right:15px; ">
						<div class="form-group col-lg-2">
							<div class="input-group">
								<span class="input-group-addon">仓库名称</span>
								<input type='text' id="stockroomName" name="stockroomName" class="form-control  required" value=""/>
							</div>
						</div>
						<div class="form-group col-lg-2">
							<div class="input-group">
								<span class="input-group-addon">订单类型</span>
								<select class="form-control" id="rentType">
									<option value="all">全部</option>
									<option value="0">租赁</option>
									<option value="2">售卖</option>
									<option value="3">领用</option>
									<option value="1" selected>接管</option>
									<option value="4">复壮</option>
								</select>
							</div>
						</div>
						<div class="form-group col-lg-2">
							<div class="input-group">
								<span class="input-group-addon">订单号</span>
								<input name="orderNo" id="orderNo" class="form-control" type="text">
							</div>
						</div>
						<div class="form-group col-lg-2">
							<div class="input-group">
								<span class="input-group-addon">创建人</span>
								<input name="createName" id="createName" class="form-control" type="text">
							</div>
						</div>
						<!-- <div class="form-group col-lg-2">
							<div class="input-group">
								<span class="input-group-addon">仓库名称:</span>
								<div class='input-group date' id='beginCreateTime' style="left: -10px;" >
									<input type='text'  name="beginCreateTime" class="form-control"  />
									<span class="input-group-addon">
										<span class="glyphicon glyphicon-calendar"></span>
									</span>
									<input type='text'  name="beginCreateTime" class="form-control"  />
									<span class="input-group-addon">
										<span class="glyphicon glyphicon-calendar"></span>
									</span>
								</div>
							</div>
						</div> -->
					</div>
					<div class="row" style="margin-top:15px">
						<div class="col-sm-6"></div>
						<div class="col-sm-3" style="text-align:center;">
							<button onclick="subForm()" type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary">
								查询
							</button>
							<button onclick="resca()" type="button" style="margin-left:50px" id="btn_query" class="btn btn-large">
								重置
							</button>
						</div>
						<div class="col-sm-3"></div>
					</div>
				</div>
			</div>
		</div>

		<script type="text/javascript">
			function exportAllCode(){
				var arr=new Array();
				var row=$("#table").bootstrapTable('getSelections');
				if(row.length==0){
					layer.alert('请选择需要打码的出库单', {
						icon: 5,
						title: "提示"
						});
				}else{
					for(var i=0;i<row.length;i++){
						arr.push(row[i].id);	
					}
					var hrefLink="${ctx}/sc/order/order/exportAllCodeV2?orderIds="+arr;
					window.open(hrefLink);
				}
			}
			
		</script>
		<div id="toolbar" class="btn-group">
			<button id="exportAllCode" type="button" class="btn btn-default" onclick="exportAllCode()">
				<span class="glyphicon glyphicon-import">批量打码</span>
			</button>
		</div>

		<!-- 列表list -->
		<table id="table"></table>
	</div>
</body>

</html>